package com.gexiaobao.pigeon.ui.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.gexiaobao.pigeon.R
import com.gexiaobao.pigeon.app.base.DataBindBaseViewHolder
import com.gexiaobao.pigeon.app.model.bean.OrderListResponse
import com.gexiaobao.pigeon.databinding.ItemOrderListBinding

/**
 * @Author      : hxw
 * @Date        : 2023/4/23 11:31
 * @Describe    :
 */
class BankCardListAdapter(data: ArrayList<OrderListResponse.ListBean>) : BaseQuickAdapter<OrderListResponse.ListBean, DataBindBaseViewHolder>(
    R.layout.item_order_list,
    data
) {

    override fun convert(holder: DataBindBaseViewHolder, item: OrderListResponse.ListBean) {
        val binding: ItemOrderListBinding = DataBindBaseViewHolder.getBinding(holder) as ItemOrderListBinding
        binding.data = item
        binding.executePendingBindings()//防止列表抖动

        val bgDrawableId: Int
        val orderTypeDrawableId: Int

        when (item.orderType) {
            2 -> {
                bgDrawableId = R.drawable.round_btn_white20_b_g_shangcheng
                orderTypeDrawableId = R.drawable.shape_round_white_shangcheng
            }
            else -> {
                bgDrawableId = R.drawable.round_btn_white20_b_g_pingtai
                orderTypeDrawableId = R.drawable.shape_round_white_pingtai
            }
        }
        holder.setBackgroundResource(R.id.order_item_ll, bgDrawableId)
        holder.setBackgroundResource(R.id.order_item_big_type_tv, orderTypeDrawableId)
    }
}